package com.orange.core.pojo.entity.user;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.orange.core.pojo.entity.IIntIdModel;
import com.orange.core.pojo.entity.IOperatorModel;
import com.orange.core.validator.group.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.With;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class UserCar implements IIntIdModel<UserCar>, IOperatorModel<UserCar> {

    @NotNull(message = "请求参数不合法", groups = {Update.class})
    @TableId(type = IdType.AUTO)
    private @With Integer id;

    private Integer userId;

    /**
     * 用户编号
     */
    @TableField(exist = false)
    private String userNo;

    /**
     * 用户昵称
     */
    @TableField(exist = false)
    private String userNickname;

    /**
     * 车牌号
     */
    @Size(max = 8, message = "请输入正确的车牌号")
    @NotBlank(message = "请输入车牌号")
    private String plateNo;

    /**
     * 车牌前缀，前端不传
     */
    private String platePrefix;

    /**
     * 车牌后缀，前端不传
     */
    private String plateSuffix;

    @TableLogic
    private Long del;

    /**
     * 创建时间
     */
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime createTime;

    /**
     * 创建人ID
     */
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @TableField(fill = FieldFill.INSERT)
    private Integer createBy;

    /**
     * 更新时间
     */
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime updateTime;

    /**
     * 更新人
     */
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Integer updateBy;
}
